﻿#include "BinaryTreeBasicHandler.h"

// 递归遍历 / 部分基础函数测试
void test1()
{
	TreeNode* root = CreateDisplayBinaryTree();
	PreOrderByRecursion(root);
	printf("\n");
	MidOrderByRecursion(root);
	printf("\n");
	PostOrderByRecursion(root);
	printf("\n");

	printf("node size: %d\n", BinaryTreeSize(root));
	printf("k level node size: %d\n", BinaryTreeKLevelSize(root, 3));
	printf("leaf node size: %d\n", BinaryTreeLeafSize(root));

	TreeNode* ret1 = BinaryTreeFind(root, 'B');
	TreeNode* ret2 = BinaryTreeFind(root, 'G');

	if (ret1) printf("find B success\n");
	else printf("B no found\n");

	if (ret2) printf("find G success\n");
	else printf("G no found\n");

	if (BinaryTreeComplete(root))
	{
		printf("is complete\n");
	}
	else
	{
		printf("not complete");
	}

	DestoryBinaryTree(root);
}

// 前序序列构造二叉树测试
void test2()
{
	char str[] = "abc##de#g##f###";
	int i = 0;
	TreeNode* root = CreateBinaryTreeByPreOrderString(str, &i);

	MidOrderByRecursion(root);
	printf("\n\n");

	LevelOrder(root);
	
	if (BinaryTreeComplete(root))
	{
		printf("is complete\n");
	}
	else
	{
		printf("not complete");
	}
}


int main()
{
	test2();
	return 0;
}